package main

import "fmt"

func main() {
	aint01 := 1
	ptr01 := &aint01
	fmt.Println(ptr01, aint01)

	astr01 := new(string)
	*astr01 = "Go编程时光"
	fmt.Println(astr01, *astr01)

	aint02 := 1
	var bint02 *int
	bint02 = &aint02
	fmt.Println(bint02, aint02)

	aint03 := 1      // 定义普通变量
	ptr03 := &aint03 // 定义指针变量
	fmt.Println("普通变量存储的是：", aint03)
	fmt.Println("普通变量存储的是：", *ptr03)
	fmt.Println("指针变量存储的是：", &aint03)
	fmt.Println("指针变量存储的是：", ptr03)

	astr04 := "hello"
	aint04 := 1
	abool04 := false
	arune04 := 'a'
	afloat04 := 1.2
	fmt.Printf("astr04指针类型是: %T\n", &astr04)
	fmt.Printf("aint04指针类型是: %T\n", &aint04)
	fmt.Printf("abool04指针类型是: %T\n", &abool04)
	fmt.Printf("arune04指针类型是: %T\n", &arune04)
	fmt.Printf("afloat04指针类型是: %T\n", &afloat04)

	a01 := 25
	var b01 *int
	if b01 == nil {
		fmt.Println(b01)
		b01 = &a01
		fmt.Println(b01)
	}

	a02 := [3]int{89, 90, 91}
	modify01(a02[:])
	fmt.Println(a02)
	a03 := [3]int{89, 90, 91}
	modify02(&a03)
	fmt.Println(a03)
}

func modify01(sls []int) {
	sls[0] = 90
}

func modify02(arr *[3]int) {
	(*arr)[0] = 90
}
